<!--
Author: Quan Van Sinh
Email : sinhvnb@vietnambiz.com
Mobile: 0972405165
-->
<?php include ADMIN_INCLUDE_DIR."/header.php";?>
<script language="javascript" type="text/javascript">
    var popupImageParams = '&forModule=news&position=content';
    $(document).ready(function (){
        CKEDITOR.config.resize_enabled = false;
        CKEDITOR.config.width = 500;
        CKEDITOR.config.height = 400;
        CKEDITOR.replace( 'content',
        {
            toolbar :
                [['Maximize', '-','Format','Font','FontSize','-','TextColor','BGColor','-','Bold','Italic','Underline','Strike','-','NumberedList','BulletedList','-','Outdent','Indent','Blockquote','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock', '-','Image','Table','-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink' ]]
        });

    });

    function keyword_remove(no){
        if($("#removedTags").val()==''){
            $("#removedTags").val($("#removedTags").val() + $("#key"+no).val())
        }else{
            $("#removedTags").val($("#removedTags").val() + ',' + $("#key"+no).val());
        }
        $('#k'+no).html('');
        $('#k'+no).hide()
        $("#keywordAlert").hide();
        $("#keywordAlert").html('<span style="color:green;">Remove keyword successful!</span>');
        $("#keywordAlert").show();
    }

    function keyword_spam(no){
        if(no!=''){
            if($("#removedTags").val()==''){
                $("#removedTags").val($("#removedTags").val() + $("#key"+no).val())
            }else{
                $("#removedTags").val($("#removedTags").val() + ',' + $("#key"+no).val());
            }
            $.ajax({
                url: ADMIN_URL+'/index.php?module=news&action=gen-tags',
                type: 'GET',
                data: "keyword=" + $("#key"+no).val(),
                error: function(){
                    alert('Error add spam!');
                },
                success: function(){
                    $("#keywordAlert").hide('slow');
                    $('#k'+no).html('');
                    $('#k'+no).hide()
                    $("#keywordAlert").html('<span style="color:green;">Add to spam successful!</span>');
                    $("#keywordAlert").show('slow');
                }
            });
        }
    }
    function submitFormAddNews(submitType){
        if(submitType=='exit'){
            $("#submitType").val('exit');
            $("#submitFrmNewsAdd").click();
        }
    }
</script>

<?php $rsNewsEdit = editUpdateNews();?>

<div class="container_l">
    <form name="formNewsAddCategory" method="POST" action="">
        <div class="title_user"><img src="images/icon1.gif" />Tin tức</div>
        <div class="table_user">
            <div class="table_user_in2">
                <?php
                show_error();
                show_success();
                ?>
                <fieldset>
                    <legend accesskey="N">Cập nhật Tin tức</legend>
                    <div class="lineaddnew">
                        <div style="width:70%;float:left;">
                            <div class="lineform">
                                <div class="divlabel_news">Tiêu đề: <font color="#FF0000">*</font></div>
                                <div class="divform">
                                    <input type="hidden" name="id" value="<?php echo $rsNewsEdit['rsNewsEdit']['id'];?>"/>
                                    <input type="text" name="title" value="<?php echo htmlentities($rsNewsEdit['rsNewsEdit']['title'], ENT_COMPAT, 'UTF-8');?>"/>
                                </div>
                            </div>
                            <div class="lineform">
                                <div class="divlabel_news">Danh mục: <font color="#FF0000">*</font></div>
                                <div class="divform">
                                    <select name="cat_id">
                                        <?php
                                        $arrNewsCat = listAllNewsCategory($parent_id = 0);
                                        for($i=0;$i<count($arrNewsCat);$i++) {
                                            ?>
                                        <option <?php echo setSelectedBoxValue($rsNewsEdit['rsNewsEdit']['cat_id'], $arrNewsCat[$i]['cat_id']);?> value="<?php echo $arrNewsCat[$i]['cat_id'];?>"><?php echo $arrNewsCat[$i]['cat_title'];?></option>
                                        <?php
                                        }
                                        ?>
                                    </select>
                                </div>
                            </div>
                            <div class="lineform">
                                <div class="divlabel_news">Mô tả ngắn: <font color="#FF0000">*</font></div>
                                <div class="divform"><textarea name="description" cols="10" rows="10" style="overflow:hidden;"><?php echo $rsNewsEdit['rsNewsEdit']['description'];?></textarea></div>
                            </div>
                            <div class="lineform">
                                <div class="divlabel_news">Hình ảnh:</div>
                                <div class="divform">
                                    <input type="hidden" id="image" name="image" value="<?php echo $rsNewsEdit['rsNewsEdit']['image'];?>"/>
                                    <img id="imgDisplay" src="<?php if($rsNewsEdit['rsNewsEdit']['image']!='') {echo $rsNewsEdit['rsNewsEdit']['image'];}else {echo 'images/no_image.jpg';}?>" style="float:left;" alt=""/>&nbsp;&nbsp;
                                    <input type="button" value="Select image" onclick="popupImages('');" class="button" style="float:left;width:120px;margin-left:20px;margin-top:65px;" />
                                </div>
                            </div>
                            <div class="lineform">
                                <div class="divlabel_news">Thể loại:</div>
                                <div style="margin-top:6px;">&nbsp;&nbsp;&nbsp;<input type="radio" name="type" value="hot" <?php echo setCheckedBoxValue($rsNewsEdit['rsNewsEdit']['active'],'hot');?> /> Hot news &nbsp;&nbsp; <input type="radio" name="type" value="normal" <?php echo setCheckedBoxValue($rsNewsEdit['rsNewsEdit']['type'],'normal',true);?> /> Normal news</div>
                            </div>

                            <div class="lineform">
                                <div class="divlabel_news">Nội dung: <font color="#FF0000">*</font></div>
                                <div style="margin-left:16%;">
                                    <textarea name="content" id="content" cols="2" rows="10"><?php echo $rsNewsEdit['rsNewsEdit']['content'];?></textarea>
                                </div>
                            </div>
                        </div>
                        
                    </div>
                    <div class="spacer1"><span></span></div>
                </fieldset>
                <div class="linesubmit">
                    <input type="hidden" name="submitType" id="submitType" value="">
                    <input type="submit" name="submitFrmNewsAdd" id="submitFrmNewsAdd" value="Lưu lại" class="button" />
                    <input type="button" name="submitFrmNewsAddAndExit" onclick="document.location='?module=news';" value="Thoát" class="button" />
                </div>
            </div>
        </div>
    </form>
</div>
<?php
include "inc/right.php";
include ADMIN_INCLUDE_DIR."/footer.php";
?>